#pragma once

#include <assert.h>
#include <errno.h>

#ifdef WIN32
//#include <winsock.h>
#else
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

#endif

typedef unsigned char       UInt8;
typedef signed char         SInt8;
typedef unsigned short      UInt16;
typedef signed short        SInt16;
typedef unsigned int        UInt32;
typedef signed int          SInt32;
typedef signed long long    SInt64;
typedef unsigned long long  UInt64;
typedef float               Float32;
typedef double              Float64;

namespace host {


    typedef enum
    {
        OS_NoErr = 0,
        OS_ErrPerm = EPERM,
        OS_ErrNoEnt = ENOENT,
        OS_ErrIntr = EINTR,
        OS_ErrIO = EIO,
        OS_ErrNXIO = ENXIO,
        OS_Err2Big = E2BIG,
        OS_ErrNoExec = ENOEXEC,
        OS_ErrBadF = EBADF,
        OS_ErrChild = ECHILD,
        OS_ErrDeadLK = EDEADLK,
        OS_ErrNoMem = ENOMEM,
        OS_ErrAcces = EACCES,
        OS_ErrFault = EFAULT,
        OS_ErrNotBlk,
        OS_ErrBusy = EBUSY,
        OS_ErrExist = EEXIST,
        OS_ErrXDev = EXDEV,
        OS_ErrNodeV = ENODEV,
        OS_ErrNotDir = ENOTDIR,
        OS_ErrIsDir = EISDIR,
        OS_ErrInval = EINVAL,
        OS_ErrNFile = ENFILE,
        OS_ErrMFile = EMFILE,
        OS_ErrNoTty = ENOTTY,   
        OS_ErrTxtBSY = ETXTBSY,
        OS_ErrFBig = EFBIG,
        OS_ErrNOSPC = ENOSPC,
        OS_ErrSPIPE = ESPIPE,
        OS_ErrROFS = EROFS,
        OS_ErrMLink = EMLINK,
        OS_ErrPipe = EPIPE,
        OS_ErrDom = EDOM,
        OS_ErrRange = ERANGE,
        OS_ErrAgain = EAGAIN,
        OS_ErrWOULDBLOCK = EWOULDBLOCK,
        OS_ErrInProg = EINPROGRESS,
        OS_ErrAlready = EALREADY,
        OS_ErrNotSock = ENOTSOCK,
        OS_ErrDestAddrReq = EDESTADDRREQ,
        OS_ErrMsgSize = EMSGSIZE,
        OS_ErrProto = EPROTOTYPE,
        OS_ErrNOPROTOOPT = ENOPROTOOPT,
    }OSErr;

    class OS
    {
    public:
        static void SleepMS(UInt32 ms);
        static void Sleep(UInt32 sec);
        static int GetErrno();

        static unsigned short Ntohs(unsigned short val);
        static unsigned int   Ntohl(unsigned int val);
        static unsigned short Htons(unsigned short val);
        static unsigned int   Htonl(unsigned int val);
    private:
    };
};
